<?php
// classes
class TableColumn
{
    var $table;  // table name for Column info
    //var $

    var $row;
    var $result;
    //    var $owner;
    var $aMySQLType;


    function TableColumn($tablename, $aMySQLType_p)
    {
        $table = $tablename;
        $this->result = mysql_query("SHOW COLUMNS FROM $table");
        $this->aMySQLType = $aMySQLType_p;
        //		echo "V: $version <p>";


        // 	    $resultsnumber = mysql_numrows($result);

        //		$this->row =

        //			mysql_free_result($result);
    }

    function getTypeSize($ColName)
    {
        // reset pointer in array
        mysql_data_seek($this->result,0);

        while (list($Field  ,$Type  ,$Null  ,$Key ,$Default, $Extra  ) = mysql_fetch_array ($this->result)) {
            if($Field == $ColName) {
                break;
            }
            $Field  = "";$Type  = "";$Null  = "";$Key = "";$Default= ""; $Extra  = "";
        }
        // pull apart $type to get actual type and size
        //		echo "found field: $Field :: $Type<p>";

        foreach ($this->aMySQLType as $MYSQLType => $tmpHTMLcode) {
            //			echo "Value: ".strtoupper($Type)."===".strtoupper($MYSQLType)."--- ".strpos(strtoupper($Type), strtoupper($MYSQLType))."<br />\n";
            //if(ereg(strtolower ($MYSQLType),  strtolower ($ColName))) {

            if(strpos(strtoupper($Type), strtoupper($MYSQLType))===0){
                //				echo "TRUE<p>";
                break;
            }

            $MYSQLType =null;
        }

        // use to get size
        $size = substr($Type, strlen($MYSQLType));
        $size = trim(strtr($size,"("," "));
        $size = trim(strtr($size,")"," "));
        if(strpos($size, ",0")>0){
            $size = substr($size,0 ,strpos($size, ",0"));
        }
        //		print $size."<p>"; // prints @example.com

        $ColType = $MYSQLType;
        $ColSize = $size;

        return array($ColType, $ColSize)	;
    }

}






/*
class mpge
{
    var $FamilyId;
    var $PageNum;

    function TableColumn($FID, $PN){
        $this->PageNum = $PN;
        $this->FamilyId= $FID;
    }

}
 *
 */
////////////////////////////





    ?>
